package com.landian.commons.jpa.converter;

import com.landian.commons.jpa.criteria.Predicable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * PredicableUtils
 * @author caojl
 * @create 2017/12/14
 **/
public class PredicableConverter {

    /**
     * TODO 尝试重构为工具类 例子；Predicable[] arr = likeList.toArray(new Predicable[likeList.size()]);
     * 将Predicate不定参数转换为数组，null被忽略
     * @param predicableArr
     * @return
     */
    public static List<Predicable> asList(Predicable... predicableArr){
        if(null == predicableArr || predicableArr.length < 1){
            return Collections.emptyList();
        }
        List<Predicable> list = new ArrayList<>();
        for (Predicable predicable : predicableArr) {
            if(null != predicable){
                list.add(predicable);
            }
        }
        return list;
    }

}